import { Action, ActionKey, actionManager, validateRuleSelectWindow } from "@/mdesign-lib/mdesign-app.umd.js";

export class ValidateRuleAction extends Action {
  keyName = ActionKey.validateRule;

  desc = "校验规则";

  onSysMenuClick() {
    this.run();
  }
  async run() {
    const project = app.activeProject;
    if (!project) return;

    validateRuleSelectWindow.popup({ projectId: project.id }, async res => {
      if (res.success) {
        validateRuleSelectWindow.done();
        if (res.checkStart) {
          actionManager.getAction(ActionKey.validateConfig)?.run();
        }
      }
    });
  }
}
